package uit.bus;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.SharedPreferences;

import com.google.android.maps.MapView;

public class RadioDialog extends Activity implements OnClickListener {

	public AlertDialog.Builder buider;
	public Context context;
	public String[] items = { "Bản đồ", "Vệ tinh" };
	public int modeView = -1;
	public MapView mapView;
	public SharedPrefren share;
	public SharedPreferences sharePre;

	public RadioDialog(Context context, MapView map, SharedPreferences sharedPre) {
		super();
		this.context = context;
		this.sharePre = sharedPre;
		mapView = map;
		share = new SharedPrefren(sharedPre);
		modeView = share.getModeView();
		buider = new AlertDialog.Builder(context);
		buider.setTitle("Chọn chế độ xem");
		buider.setIcon(android.R.drawable.ic_menu_view);
		buider.setSingleChoiceItems(items, modeView, this);
		buider.setPositiveButton("OK", this);
		buider.show();
	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
		// TODO Auto-generated method stub

		switch (which) {
		case 0:
			if (mapView.isSatellite()) {
				share.setModeView(which);
				mapView.setTraffic(true);
				mapView.setSatellite(false);
				mapView.invalidate();
			}
			break;
		case 1:
			if (mapView.isTraffic()) {
				share.setModeView(which);
				mapView.setSatellite(true);
				mapView.setTraffic(false);
				mapView.invalidate();
			}
			break;
		default:
			break;

		}
	}
}
